import Vue from 'vue'
import Router from 'vue-router'

const homepage = () => import("../components/homepage.vue")

const rankdetail = () => import("../components/content/ranklist/rankdetail.vue")
const rank = () => import("../components/content/ranklist/rank.vue")
const songList = () => import("../components/content/ranklist/songList.vue")
const songDetail = () => import("../components/songdetail/songdetail.vue")
const contents = () => import("../components/content/contents.vue")

const recommendation = () => import("../components/content/recommendation/recommendation.vue")
const singer = () => import("../components/content/singer/singer.vue")
const songlist = () => import("../components/content/songlist/songlist.vue")
const newestsong = () => import("../components/content/newestsong/newestsong.vue")
const hoststation = () => import("../components/content/hoststation/hoststation.vue")
const newdisc = ()=>import("../components/content/newestsong/newdisc.vue")

const mv = ()=>import("../components/mv/mv.vue")
const searchmatch = ()=>import('../components/searchmatch/searchmatch.vue')
const singerRank = ()=>import('../components/content/singer/singerRank.vue')
const singerDetail= ()=>import('../components/content/singer/singerDetail.vue')

const boutiquePlaylist = () => import("../components/content/songlist/boutiquePlaylist.vue")

Vue.use(Router)

const router = new Router({
  routes: [{
      path: '/',
      redirect: "/homepage"
    },
    {
      path: '/homepage',
      name: 'homepage',
      meta: {
        title: "首页"
      },
      component: homepage,
      children: [{
          path: "",
          redirect: "contents"
        },

        {
          path: "contents",
          name: "contents",
          component: contents,
          meta: {
            title: "个性推荐"
          },
          children: [{
              path: "",
              redirect: "recommendation"
            },
            {
              path: "recommendation",
              name: "recommendation",
              component: recommendation,
              meta: {
                title: "个性推荐"
              },
            },
            {
              path: "searchmatch",
              name: "searchmatch",
              component: searchmatch,
              meta: {
                title: "搜索匹配"
              },
            },
            {
              path: "singer",
              name: "singer",
              component: singer,
              meta: {
                title: "歌手"
              },
            },
            {
              path: "singerRank",
              name: "singerRank",
              component: singerRank,
              meta: {
                title: "歌手榜"
              },
            },
            {
              path: "singerDetail",
              name: "singerDetail",
              component: singerDetail,
              meta: {
                title: "歌手详情"
              },
            },
            {
              path: "songlist",
              name: "songlist",
              component: songlist,
              meta: {
                title: "歌单"
              },
            },
            {
              path: "boutiquePlaylist",
              name: "boutiquePlaylist",
              meta: {
                title: "精品歌单"
              },
              component: boutiquePlaylist,
            },
            {
              path: "newestsong",
              name: "newestsong",
              component: newestsong,
              meta: {
                title: "最新音乐"
              },
            },
            {
              path: "newdisc",
              name: "newdisc",
              component: newdisc,
              meta: {
                title: "最新音乐"
              },
            },
            {
              path: "hoststation",
              name: "hoststation",
              component: hoststation,
              meta: {
                title: "主播电台"
              },
            },
            {
              path: "rank",
              name: "rank",
              component: rank,
              meta: {
                title: "排行榜"
              },
            },
            {
              path: "rankdetail",
              name: "rankdetail",
              component: rankdetail,
              children: [{
                  path: "",
                  redirect: "songList"
                },
                {
                  path: "songList",
                  name: "songList",
                  meta: {
                    title: "排行榜歌单"
                  },
                  component: songList,
                },
              ]
            },
          ]
        },
        {
          path: "/songdetail",
          name: "songdetail",
          component: songDetail,
          meta: {
            title: "歌曲详情"
          },
        },
        {
          path: "/mv",
          name: "mv",
          component: mv,
          meta: {
            title: "MV详情"
          },
        },
        
      ]
    },

  ],
  mode: "history",
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
})

export default router
